<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>发送请求</button>


    <script>
        let btn = document.getElementsByTagName('button')[0]
        const xhr = new XMLHttpRequest()
        //防抖
        let isSended = false

        btn.onclick =function(){
            if(isSended) xhr.abort()
            xhr.open('GET','http://localhost:8000/delay')
            xhr.send()
            isSended = true;
            xhr.onreadystatechange = function(){
                if(xhr.readyState == 4){
                    isSended = false;
                }
            }
        }



    </script>
</body>
</html>